package Code.Day11_20241012.com.dx.day11;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @ClassName FileTest02
 * @Description 目录与遍历目录
 * @Author 12994
 * @Date 2024/10/12 10:45
 * @Version 1.0
 **/
public class FileTest02 {
    public static void main(String[] args) {
        File file = new File("./");
        if (file.isDirectory()) {
            ArrayList<File> files1 = new ArrayList<>(List.of(Objects.requireNonNull(file.listFiles())));
            files1.forEach(System.out::println);
        }
    }

    public static void outputFile(String file) {
        try {
            Reader reader = new FileReader(file);
            for (; ; ) {
                int n = reader.read();
                if (n == -1) {
                    break;
                }
                System.out.print(n);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
